﻿using EONFULLSIN2.Common;
using EONFULLSIN2.Core.Extensions;
using HandyControl.Data;
using HandyControl.Properties.Langs;
using HandyControl.Tools;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EONFULLSIN2.Controls {
    /// <summary>
    /// NonClientAreaControl.xaml 的交互逻辑
    /// </summary>
    public partial class NonClientAreaControl : UserControl {
        public NonClientAreaControl() {
            InitializeComponent();
        }

        private void ButtonLangs_OnClick(object sender, RoutedEventArgs e) {
            if (e.OriginalSource is Button { Tag: string langName }) {
                PopupConfig.IsOpen = false;
                if (langName.Equals(AppInfo.Config.Lang)) {
                    return;
                }
                AppInfo.Config.Lang = langName;
                AppInfo.SaveAppConfig();
                ((App)Application.Current).UpdateLang(langName);
            }
        }

        private void ButtonConfig_OnClick(object sender, RoutedEventArgs e) => PopupConfig.IsOpen = true;

        private void ButtonSkins_OnClick(object sender, RoutedEventArgs e) {
            if (e.OriginalSource is Button { Tag: SkinType skinType }) {
                PopupConfig.IsOpen = false;
                if (skinType.Equals(AppInfo.Config.Skin)) {
                    return;
                }

                AppInfo.Config.Skin = skinType;
                AppInfo.SaveAppConfig();
                ((App)Application.Current).UpdateSkin(skinType);
            }
        }

        private void MenuAbout_OnClick(object sender, RoutedEventArgs e) {
            //new AboutWindow {
            //    Owner = Application.Current.MainWindow
            //}.ShowDialog();
        }
    }
}
